<?php
/*
 *@des 后台的基类,初始化一些变量之类的
 *@author www.speakphp.com 
 */
$group  =  defined('GROUP_NAME')?GROUP_NAME.'/':'';
$theme  =   C('DEFAULT_THEME');
// 获取当前主题的模版路径
if(1==C('APP_GROUP_MODE')){ // 独立分组模式
	define('APP_TMPL_PATH',__ROOT__.'/'.APP_NAME.(APP_NAME?'/':'').C('APP_GROUP_PATH').'/'.$group.basename(TMPL_PATH).'/'.$theme);
}else{
	define('APP_TMPL_PATH',__ROOT__.'/'.APP_NAME.(APP_NAME?'/':'').basename(TMPL_PATH).'/'.$group.$theme);
}
class AdmincommonAction extends Action {
	public $visitor = array() ; //用户的基本信息
	public $site_config = array()  ; //站点基本信息
	public $_cookie_data = array() ;
	public $_url_data = array() ;
	public $username = '' ;
	public $uid = '' ; 
	public $group_name = '' ;//组
	public $is_login = false ; //是否登录 默认没有
  	public function __construct(){
  		parent::__construct();
  	}
  	//检测是否登录并且赋值
  	public function _is_login(){
  		$data = $this->_cookie_data = decode_data(cookie("admin_auth")); //获取cookie数据
  		if(isset($data['username']) && $data['username'] ){
  			$this->username = $data['username'];
  			$this->uid = $data['id'];
  			$this->group_name = $data['group_name'];
  			$this->is_login = true ;
  		}
  	}
  	//检查是否登录了
  	public function check_is_login($data = '' ){
  		$this->_is_login();
  		if(empty($this->username) || $this->username == ""  ){
  			if($this->_request("showpage")!= "" ){ //这个地方是为了判断 ，ajax请求，但是显示的是一个提示页面
  				throw_exception("对不起登陆超时或者你还没登陆！");
  				//echo "对不起登陆超时，或者你还没登陆";
  				die();
  			}
  			//如果没有登录
  			if(isset($_GET['inajax']) || $this->isAjax()){
  				echo result_to_towf_new('',-8,"你的密码已经过期,重新登录",null);
  				die();
  			}
  			$this->error("密码已经过期" ,U("login/index") );
  		}
  		$this->visitor = $data ;
  	}
}
